import com.alibaba.excel.EasyExcel;
import com.example.pojo.easyexcel.model.CustomerConvertData;
import org.junit.Test;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/9/27 18:23
 */

public class CustomeConvert {

    public static final String FILE_PATH=System.getProperty("user.dir")+"\\src\\main\\resources\\CustomerConvertData.xlsx";

    @Test
    public void test1(){
        EasyExcel.write(FILE_PATH,CustomerConvertData.class).sheet("模板").doWrite(getData());
    }

    public static List<CustomerConvertData> getData(){
        List<CustomerConvertData> list=new ArrayList<>(10);
        for (int i = 0; i <10 ; i++) {
            CustomerConvertData customerConvertData= CustomerConvertData.builder()
                    .id(i)
                    .name("测试数据"+i)
                    .status(i%2)
                    .createTime(LocalDateTime.now())
                    .build();
            list.add(customerConvertData);
        }
        return list;
    }
}
